package from;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListChoicePage extends WebPage {

    private static List SITES = new ArrayList();
    private static Map NAMES = new HashMap();

    static {
        SITES.add("http://aa.com");
        SITES.add("http://bb.com");
        SITES.add("http://cc.com");

        NAMES.put("http://aa.com", "aa");
        NAMES.put("http://bb.com", "bb");
        NAMES.put("http://cc.com", "cc");
    }

    public ListChoicePage(){
        super();

        Form<Object> form = new Form<>("formLC");
        add(form);

        IChoiceRenderer renderer = new ChoiceRenderer(){
            public Object getDisplayValue(Object o){
                return NAMES.get(o);
            }
        };

        ListChoice siteChoice = new ListChoice("sites", SITES, renderer);
        //多选
//        ListMultipleChoice siteMultiChoice = new ListMultipleChoice("sitesMulti", SITES, renderer);
        form.add(siteChoice);

    }
}
